home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #6 / Amiga Plus CD - 2004 - No. 06.iso / AmigaPlus / Begleitmaterial / 50Tools / Grafik / PerfectPaint / rexx / general / LoadTransferAnim.rx < prev    next >
Text File  |  2001-10-01  |  3KB  |  198 lines

  1. /*     arexx Script 
  2. */
  3.  
  4.     call addlib("rexxmathlib.library", 5, -30, 0)
  5.  
  6.     options results
  7.     parse ARG Port b
  8.     
  9.     ADDRESS value Port
  10.  
  11.     if EXISTS('PerfectPaint:Prefs/Rexx_Prefs/LTransferAnim') THEN DO
  12.         IF OPEN('lfile','PerfectPaint:Prefs/Rexx_Prefs/LTransferAnim', "R") then DO
  13.             file = READLN('lfile')
  14.             CALL CLOSE('lfile')
  15.             file2=""
  16.             do i=1 to LENGTH(file)
  17.                 a=SUBSTR(file,i,1)
  18.                 if a=" " then DO
  19.                     a="*"
  20.                 END
  21.                 file2=file2||a
  22.             END
  23.             file=file2
  24.         END
  25.     END
  26.  
  27.     pp_DialogInit 250 80 "*Load*Transfer*Animation" 2
  28.         pp_String 0 50 12 150 16 "file" 1 100 file
  29.         n=LASTPOS('/',file)
  30.         if n=0 then DO
  31.             n=LASTPOS(':',file)
  32.             file=SUBSTR(file,1,n)
  33.         END
  34.         else DO            
  35.             file=SUBSTR(file,1,n)
  36.         END
  37.         pp_Getfile 1 205 13 0 "Select*Path" 0 file
  38.     pp_Dialog    
  39.  
  40.     rc=result
  41.     if rc=0 then
  42.         do
  43.             pp_PermitRefresh            
  44.             EXIT
  45.         end    
  46.  
  47.     pp_GetDialog 0
  48.     file=result
  49.  
  50.     CALL SavePrefs('LTransferAnim',file)
  51.  
  52.     Width=0
  53.  
  54.     if ~exists(file||'.info') then DO
  55.         pp_Warn "Can't*find*'.info'*file."
  56.         pp_DialogInit 250 80 "*Load*Transfer*Animation" 1
  57.             pp_integer 3 50 12 70 16 "Width*of*one*frame" 1 Width
  58.         pp_Dialog
  59.         rc=result
  60.         if rc=0 then DO
  61.             pp_PermitRefresh            
  62.             EXIT
  63.         end
  64.         pp_GetDialog 0
  65.         Width=result            
  66.     END        
  67.         
  68.     if Width=0 then DO
  69.         pp_FindToolvalue file "WIDTH"
  70.         IF result~="" then DO
  71.             Width=result
  72.         END
  73.         ELSE DO
  74.             pp_FindToolvalue file "SIZE"
  75.             IF result~="" then DO
  76.                 W1=LASTPOS(",",result)
  77.                 Width=SUBSTR(result,1,W1-1)                
  78.             END            
  79.             ELSE DO            
  80.                 pp_FindToolValue file "FRAMEWIDTH"
  81.                 IF result~="" then DO    
  82.                     Width=result
  83.                 END    
  84.             END
  85.         END
  86.     END
  87.  
  88.     pp_GetCurrentBuffer
  89.     CBf=result
  90.     pp_GetCurrentBrush
  91.     B0=result    
  92.  
  93.     pp_Load file
  94.     
  95.     pp_GetDepth
  96.     D=result
  97.     pp_GetWidth
  98.     W=result
  99.     pp_GetHeight
  100.     H=result
  101.  
  102.     if Width=0 then DO
  103.         Width=H
  104.     END
  105.  
  106.     if D<24 then DO
  107.         pp_Psave "ram:palette.trash" 0
  108.     END
  109.     
  110.     pp_FindEmptyBrush
  111.     Brush=result
  112.     if Brush=-1 then DO
  113.         pp_Warn "can't*find*empty|Brush."
  114.         EXIT        
  115.     END
  116.     pp_SetBrush Brush
  117.  
  118.     pp_FindEMptyBuffer
  119.     Bf=result
  120.     if Bf=-1 then DO
  121.         pp_Warn "can't*find*empty|Buffer."
  122.         EXIT        
  123.     END
  124.     pp_SetBuffer Bf
  125.  
  126.     pp_New Width H D
  127.     pp_GetWidth
  128.     if result=0 then DO
  129.         pp_Warn "Not*enough*memory."
  130.         EXIT            
  131.     END
  132.  
  133.     pp_AnimGui 1
  134.     IF result<2 then DO
  135.         EXIT
  136.     END
  137.     count=trunc(W/Width)
  138.     pp_MakeAnim count
  139.     pp_CountFrames
  140.     IF result<2 then DO
  141.         pp_Warn "Can't*create*animation."
  142.         EXIT
  143.     END
  144.  
  145.     if D<24 then DO
  146.         pp_Pload "ram:palette.trash"
  147.         ADDRESS COMMAND
  148.         'delete >nil: ram:palette.trash'
  149.         ADDRESS value Port
  150.     END
  151.  
  152.     X2=Width/2
  153.     Y2=H/2
  154.  
  155.     PB=0
  156.  
  157.     DO i=1 to count
  158.         pp_SetBuffer CBf
  159.         pp_PickBrush PB 0 Width H 1
  160.         pp_SetBuffer Bf
  161.         pp_Plot X2 Y2
  162.         pp_NextFrame
  163.         PB=PB+Width
  164.     END
  165.  
  166.     pp_SetBuffer CBf
  167.     pp_ClearCurrentBuffer
  168.     pp_SetBuffer Bf    
  169.  
  170.     pp_FreeBrush
  171.     pp_SetBrush B0
  172.  
  173.  
  174.     EXIT
  175.  
  176. SavePrefs: PROCEDURE
  177.     
  178.     Prefname='PerfectPaint:Prefs/Rexx_Prefs/'||ARG(1)
  179.  
  180.     if EXISTS(Prefname) THEN DO
  181.         ADDRESS COMMAND
  182.         'delete >nil: '||Prefname
  183.     END
  184.  
  185.     IF OPEN('pfile',PrefName,'W') THEN DO
  186.  
  187.     do i=2 to ARG()
  188.         CALL WRITELN('pfile',ARG(i))
  189.     end
  190.  
  191.     CALL CLOSE('pfile')
  192.  
  193. RETURN    
  194.  
  195.  
  196.     
  197.  
  198.